﻿@model Fap.AspNetCore.ViewModel.JqGridViewModel
<fap-grid id="jobresume" grid-model="Model" wrapper="modal-body" register-authority="false" view-records="true"  multi-select="true" multi-box-only="true" shrink-fit="false"></fap-grid>

<script>
    function setResumeStatus(status) {
        var rows = getSelectedRows("grid-jobresume");
        if (rows === null) {
            return;
        }
        var fids= $.map(rows, function (r) {
            return r.Fid;
        })
        bootbox.confirm("确定要执行此操作吗?", function (result) {
            if (result) {
                $.post(basePath + "/Recruit/Api/ResumeStatus", { fids: fids, status: status }, function (rv) {
                    if (rv.success) {
                        $.msg(rv.msg);
                        refreshGrid("grid-jobresume");
                    } else {
                        bootbox.alert(rv.msg);
                    }
                })
            }
        })
       
    }
    //简历评估
    function resumeAssess() {
        var rw = getSelectedRow("grid-jobresume");
        if (rw === null) {
            return;
        }
        var buttons = null;
        if (rw.ResumeStatus === "Screen") {
            buttons = {
                interview: {
                    label: $.lang("allow_interview", "允许面试"),
                    className: "btn-primary btn-link",
                    callback: function () {
                        setResumeStatus('Interview');
                        return false;
                    }
                }
            };
        }
        bootboxWindow($.lang("resume_assess", "简历评估"), basePath + "/Recruit/Manage/ResumeAssess", buttons,{ fid: rw.Fid, name: rw.ResumeName });
    }
    function interviewAssess() {
        var rw = getSelectedRow("grid-jobresume");
        if (rw === null) {
            return;
        }
        bootboxWindow($.lang("view_interview_assess", "查看面试评价"), basePath + "/Recruit/Manage/InterviewAssess", null, { resumeUid: rw.Fid });
    }
    //推送简历给部门
    function sendResumeToDept(demandUid) {
        var rows = getSelectedRows("grid-jobresume");
        if (rows === null) {
            return;
        }
        var sels= $.grep(rows, function (d) {
            return d.ResumeStatus === "Created";
        })
        if (sels === null || sels.length < 1) {
            $.msg("没有满足条件的简历");
            return;
        }
        var fids = $.map(sels, function (r) {
            return r.Fid;
        })
        $.post(basePath + "/Recruit/Api/ResumeToDept", { resumeUids: fids, demandUid: demandUid }, function (rv) {
            if (rv.success) {
                $.msg(rv.msg);
                refreshGrid("grid-jobresume");
            } else {
                bootbox.alert(rv.msg);
            }
        })
    }
    //面试邀约
    function setInterviewMail(demandUid) {
        var row = getSelectedRow("grid-jobresume");
        if (row == null) {
            return;
        }
        if (row.ResumeStatus === "Interview" || row.ResumeStatus === "InterviewNoticed" || row.ResumeStatus === "Interviewing") {
            bootboxWindow($.lang("send_interview_notice", "发送面试通知"), basePath + "/Recruit/Manage/InterviewNotice",
                {
                    ok: {
                        label: $.lang("ok", "确定"),
                        className: "btn-primary btn-link",
                        callback: function () {
                            return sendInterviewNotice(demandUid,row.Fid);                            
                        }
                    }
                }, { resumeUid: row.Fid });
        } else {
            $.msg("职位部门还没有批准面试，请联系职位部门批准");
        }
    }
    function sendOfferApply(demand) {
        var resume = getSelectedRow("grid-jobresume");
        if (resume == null) {
            return;
        }
        applyBusiness("3532118617262915584", "offer审批",
            {
                "DemandUid": demand.Fid,
                "ResumeUid": resume.Fid,
                "ResumeUidMC": resume.ResumeName,
                "EmpName": resume.FullName,
                "Gender": resume.Gender,
                "DeptUid": demand.DeptUid,
                "DeptCode": demand.DeptCode,
                "DeptUidMC": demand.DeptUidMC,
                "ArrivalDate": demand.EntryDate,
                "WorkingPlace": demand.WorkPlace

            });
    }
</script>